﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; 
using System.Configuration;
//using Zeus.DAL.LINQ;
using Zeus.Biz.Northwind.Model;

namespace Zeus.Biz.Northwind.DAL
{
    public class EmployeeDao
    {
        NorthwindDataContext context = new NorthwindDataContext(ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ToString());

        public List<EmployeeModel> GetAllEmployees()
        {
            var query = from emp in context.Employees
                        select new EmployeeModel
                        {
                            EmployeeID = emp.EmployeeID,
                            FirstName = emp.FirstName,
                            LastName = emp.LastName,
                            Title = emp.Title
                        };

            return query.ToList();
        }

        public EmployeeModel GetEmployeeById(int employeeId)
        {
            List<Employee> employees = context.Employees.Where(a => a.EmployeeID == employeeId).ToList();

            EmployeeModel employeeModel = new EmployeeModel
            {
                EmployeeID = employees[0].EmployeeID,
                FirstName = employees[0].FirstName,
                LastName = employees[0].LastName,
                Title = employees[0].Title
            };

            return employeeModel;
        }
    }
}
